package com.zhenhunfan.service;

import com.zhenhunfan.TestProto;
import com.zhenhunfan.TestServiceGrpc;
import io.grpc.stub.StreamObserver;

/**
 * <p>Title: 一元RPC，用于演示FutureStub的使用</p>
 * <p>Description:</p>
 *
 * @author zhanghong
 * @date 2023/7/18
 */
public class TestServiceImpl extends TestServiceGrpc.TestServiceImplBase {
    @Override
    public void test(TestProto.TestRequest request, StreamObserver<TestProto.TestResponse> responseObserver) {
        String name = request.getName();
        System.out.println("name=" + name);

        responseObserver.onNext(TestProto.TestResponse.newBuilder().setResult("响应数据："+name).build());
        responseObserver.onCompleted();
    }
}
